<template>
	<view class="deliveryAddress">
		<view class="nav">
			<view :class="index==navindex?'item check':'item'" v-for="(item,index) in nav" :key="index" @click="bindEditTabbar(index)">{{item}}</view>
		</view>
		<view class="con">
			<view class="line" v-for="(item,index) in pageResult.list" :key="index">
				<view class="address" @click="jump('business_info', item.id)">
					<view class="uni-flex uni-row">
						<view style="-webkit-flex: 1;flex: 1;font-size: 40rpx;font-weight:bold;">{{item.merchant_name}}</view>
						<view style="width: 200rpx;font-weight: 400;text-align:right;">{{item.status_name}}</view>
					</view>
					<text class="text">{{item.proposer_name}} — {{item.proposer_mobile}}</text>
					<text class="text">{{item.address}}</text>
				</view>
			</view>
		</view>
		<view v-if="pageResult.list.length == 0" class="nocontent">
			<image src="https://hdsq.aoorange.cn/attachment/xcx/icon/noItem.png" ></image>
			<!-- <text>暂无记录～</text> -->
		</view>
	</view>
</template>

<script>
	import serve from '../static/request.js';
	import storage from '../static/appkey.js';
	import common from '../static/jump.js';
	export default {
		data() {
			return {
				nav: ["待处理", "已完成"],
				navindex:0,
				pageParam: {
					appkey: uni.getStorageSync('appkey'),
					'access-token': uni.getStorageSync('access-token'),
					type : 1,
					page: 0,
					pageSize: 5
				},
				pageResult: {
					list: [],
					isEmpty: false,
					isEnd: false
				},
			}
		},
		methods: {
			bindEditTabbar(index) {
				if (index == this.navindex) {
					return ;
				}
				this.navindex = index;
				this.pageParam.type = this.navindex == 0 ? 1 : 2;
				this.pageParam.page = 0;
				this.pageResult.list = [];
				this.loadList();
			},
			loadList() {
				var self = this;
				self.pageParam.page++
				serve
					.request({
						url: '/spread/business/index',
						data: self.pageParam
					})
					.then(res => {
						console.log(res.data); 
						if (res.data && res.data.length > 0) {
							self.pageResult.list=self.pageResult.list.concat(res.data);
						}
						self.pageResult.isEmpty = self.pageResult.list.length == 0;
						self.pageResult.isEnd = res.data.length == 0; 
					});
			},
			callPhone(mobile) {
				uni.makePhoneCall({
				    phoneNumber: mobile
				});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(options) {
			this.loadList();
		},
		onPullDownRefresh() {
			console.log('下拉');
			this.pageParam.page=0;
			this.pageResult.list=[];
			this.loadList();
		},
		//触底加载
		onReachBottom() {
			console.log('触底'); 
			if(this.pageResult.isEnd ||this.pageResult.isEmpty){
				return
			}
			this.loadList();
		}
	}
</script>

<style scoped lang="scss">
	.deliveryAddress {
		padding-bottom: 100rpx;
		.nav {
			display: flex;
			align-items: center;
			height: 100rpx;
			border-bottom: 1rpx rgba(204, 204, 204, 0.3) solid;
			background: #FFFFFF;
			position: fixed;
			width: 100%;
			z-index: 10;
		
			.item {
				font-size: 32rpx;
				color: rgba(153, 153, 153, 1);
				line-height: 100rpx;
				width: 50%;
				text-align: center;
			}
		
			.check {
				position: relative;
				color: #232323;
			}
		
			.check::after {
				content: "";
				position: absolute;
				width: 30rpx;
				height: 7rpx;
				background: rgba(255, 188, 0, 1);
				border-radius: 3rpx;
				bottom: 0;
				left: 46%;
			}
		}
		.con {
			padding-top: 100rpx;
		}

		.line {
			display: flex;
			box-sizing: border-box;
			align-items: flex-start;
			padding: 60rpx 30rpx;
			position: relative;
			border-bottom: 12rpx #F8F8FA solid;

			.sel {
				background-image: url(https://hdsq.aoorange.cn/attachment/xcx/icon/xuanzhong.png);
				background-repeat: no-repeat;
				width: 40rpx;
				height: 40rpx;
				background-size: 100%;
			}

			.nosel {
				width: 36rpx;
				height: 36rpx;
				border: 1rpx solid #999999;
				border-radius: 50%;
			}

			.address {
				font-size: 32rpx;
				display: flex;
				flex-direction: column;
				width: 100%;
				margin-left: 23rpx;
				color: #333333;

				.text {
					margin-top: 32rpx;
					font-weight: 400;
					color: #666666;
				}

			}

			image {
				position: absolute;
				width: 27rpx;
				height: 33rpx;
				top: 140rpx;
				right: 30rpx;
			}
		}
		.uni-row {
		    -webkit-box-orient: horizontal;
		    -webkit-box-direction: normal;
		    -webkit-flex-direction: row;
		    flex-direction: row;
		}
		.uni-flex {
		    display: -webkit-box;
		    display: -webkit-flex;
		    display: flex;
		    -webkit-box-orient: horizontal;
		    -webkit-box-direction: normal;
		    -webkit-flex-direction: row;
		    flex-direction: row;
		}
		.nocontent{
			width: 100%;
			padding-top: 338rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			image{
				width:220rpx;
				height:220rpx;
			}
			text{
				font-size:28rpx;
				color:rgba(204,204,204,1);
			     margin-top: 30rpx;
			}
		}
	}
</style>
